package com.rankeiot;

import java.io.*;

public class Utils {
    public static String loadText(String path){
        return loadText(Utils.class.getResourceAsStream(path));
    }
    public static String loadText(InputStream is){
        StringBuilder sb = new StringBuilder();
        try(Reader reader = new InputStreamReader(is,"utf-8")) {
            BufferedReader br = new BufferedReader(reader, 512);
            int value;
            while ((value = br.read()) != -1) {
                sb.append((char) value);
            }
        } catch (IOException e) {
            e.printStackTrace();
        }finally {
            try {
                is.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return sb.toString();
    }
}
